package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "offer_details", schema = "springboot", catalog = "")
public class OfferDetails {
    private int detailsId;//报价明细id
    private String prsDiscount;//折扣
    private Integer prsNum;//数量
    private BigDecimal prsCount;//小计
    private Offer offerByOfferId2;//报价单
    private Zproductside productside;//产品副表
    private BigDecimal prsPrice;//售价
    private BigDecimal prsDiscountedPrice;//折后价

    public OfferDetails() {
    }

    public OfferDetails(int detailsId, String prsDiscount, Integer prsNum, BigDecimal prsCount, Offer offerByOfferId2, Zproductside productside, BigDecimal prsPrice, BigDecimal prsDiscountedPrice) {
        this.detailsId = detailsId;
        this.prsDiscount = prsDiscount;
        this.prsNum = prsNum;
        this.prsCount = prsCount;
        this.offerByOfferId2 = offerByOfferId2;
        this.productside = productside;
        this.prsPrice = prsPrice;
        this.prsDiscountedPrice = prsDiscountedPrice;
    }



    @ManyToOne
    @JoinColumn(name="Prs_id",referencedColumnName = "ps_id")
    public Zproductside getProductside() {
        return productside;
    }

    public void setProductside(Zproductside productside) {
        this.productside = productside;
    }

    @Id
    @Column(name = "details_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getDetailsId() {
        return detailsId;
    }

    public void setDetailsId(int detailsId) {
        this.detailsId = detailsId;
    }

    @Basic
    @Column(name = "prs_discount")
    public String getPrsDiscount() {
        return prsDiscount;
    }

    public void setPrsDiscount(String prsDiscount) {
        this.prsDiscount = prsDiscount;
    }

    @Basic
    @Column(name = "prs_num")
    public Integer getPrsNum() {
        return prsNum;
    }

    public void setPrsNum(Integer prsNum) {
        this.prsNum = prsNum;
    }

    @Basic
    @Column(name = "prs_count")
    public BigDecimal getPrsCount() {
        return prsCount;
    }

    public void setPrsCount(BigDecimal prsCount) {
        this.prsCount = prsCount;
    }

    @Basic
    @Column(name = "prs_price")
    public BigDecimal getPrsPrice() {
        return prsPrice;
    }

    public void setPrsPrice(BigDecimal prsPrice) {
        this.prsPrice = prsPrice;
    }

    @Basic
    @Column(name = "prs_discounted_price")
    public BigDecimal getPrsDiscountedPrice() {
        return prsDiscountedPrice;
    }

    public void setPrsDiscountedPrice(BigDecimal prsDiscountedPrice) {
        this.prsDiscountedPrice = prsDiscountedPrice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        OfferDetails that = (OfferDetails) o;
        return detailsId == that.detailsId &&
                Objects.equals(prsDiscount, that.prsDiscount) &&
                Objects.equals(prsNum, that.prsNum) &&
                Objects.equals(prsCount, that.prsCount);
    }

    @Override
    public int hashCode() {
        return Objects.hash(detailsId, prsDiscount, prsNum, prsCount);
    }

    @ManyToOne
    @JoinColumn(name = "offer_id2", referencedColumnName = "offer_id2")
    public Offer getOfferByOfferId2() {
        return offerByOfferId2;
    }

    public void setOfferByOfferId2(Offer offerByOfferId2) {
        this.offerByOfferId2 = offerByOfferId2;
    }


}
